﻿#define _CRT_SECURE_NO_WARNINGS 1

#include<iostream>

using namespace std;


//
//class Base {
//public:
//    ~Base() { std::cout << "Base destructor" << std::endl; }
//};
//
//class Derived : public Base {
//public:
//    ~Derived() { std::cout << "Derived destructor" << std::endl; }
//};
//
//int main() {
//    Base* ptr = new Derived();
//    delete ptr;  // 仅调用 Base 的析构函数，Derived 的析构函数不会被调用！
//    return 0;
//}

//
//class Car {
//public:
//	void Drive()//不给基类的Drive()加virtual
//	{}
//};
//class Benz :public Car {
//public:
//	virtual void Drive() override { cout << "Benz-舒适" << endl; }
//};
//int main()
//{
//	return 0;
//}

//
//// error C3248: “Car::Drive”: 声明为“final”的函数⽆法被“Benz::Drive”重写
//class Car
//{
//public:
//	virtual void Drive() final {}
//};
//class Benz :public Car
//{
//public:
//	virtual void Drive() { cout << "Benz-舒适" << endl; }
//};
//int main()
//{
//	return 0;




//
//
//
//
//class Car {
//public:
//	virtual void Drive() final
//	{}
//};
//class Benz :public Car {
//public:
//	virtual void Drive() override { cout << "Benz-舒适" << endl; }
//};
//int main()
//{
//	return 0;
//}
//
//
//class Car
//{
//public:
//	virtual void Drive() = 0;
//};
//class Benz :public Car
//{
//public:
//	virtual void Drive()
//	{
//		cout << "Benz-舒适" << endl;
//	}
//};
//
//class BMW :public Car
//{
//public:
//	virtual void Drive()
//	{
//		cout << "BMW-操控" << endl;
//	}
//};
//int main()
//{
//	// 编译报错：error C2259: “Car”: 无法实例化抽象类
//	Car car;
//	Car* pBenz = new Benz;
//	pBenz->Drive();
//	Car* pBMW = new BMW;
//	pBMW->Drive();
//	return 0;
//}


class Base
{
public:
	virtual void Func1()
	{
		cout << "Func1()" << endl;
	}
protected:
	int _b = 1;
	char _ch = 'x';
};
int main()
{
	Base b;
	cout << sizeof(b) << endl;
	return 0;
}